<?php
/* -=-=-=-=-=-=-=-=-=-=-=-=-
     author by terry
-=-=-=-=-=-=-=-=-=-=-=-=- */
error_reporting(7);
require "global.php";
cpheader();
//set offset
if(!empty($_POST[offset]))
{$offset = $_POST[offset];}
else if  (!empty($_GET[offset]))
{$offset = $_GET[offset]; }
else  {$offset = 0; }


if ($_GET[action]=="add"||$_GET[action]=='mod'||$_GET[action]=='view'){

    $cpforms->inithtmlarea();
	if($_GET[action]=="view"){
		    $cpforms->formheader(array('title'=>'View Resume (<font color=red>*</font>=Required Field)',
										'name'=>'article',
				                        'enctype'=>'multipart/form-data'));
		    $resumeid = intval($_GET[id]);
			$cpforms->makehidden(array('name'=>'id',
									   'value'=>$resumeid));
			$cpforms->makehidden(array('name'=>'offset',
									   'value'=>$offset));
            $view =1;
	        $rs  = $DB->fetch_one_array("SELECT * FROM ".$db_prefix."resume WHERE re_id =".$resumeid);

            $re_fname = $rs[re_fname];
            $re_lname = $rs[re_lname];
            $re_email = $rs[re_email];
            $re_address1 = $rs[re_address1];
            $re_address2 = $rs[re_address2];
            $re_lostate = $rs[re_lostate];
            $re_locountry = $rs[re_locountry];
            $re_locity = $rs[re_locity];
            $re_phone1 = $rs[re_phone1];
            $re_phone2 = $rs[re_phone2];
            $re_jobtype = $rs[re_jobtype];
            $re_jobindustry = $rs[re_jobindustry];
            $re_jobtitle = $rs[re_jobtitle];
            $re_crtjobtitle = $rs[re_crtjobtitle];
            $re_yearexp = $rs[re_yearexp];
            $re_edulevel = $rs[re_edulevel];
            $re_proflicense = $rs[re_proflicense];
            $re_mgmt = $rs[re_mgmt];
            $re_profit = $rs[re_profit];
            $re_spoken = $rs[re_spoken];
            $re_prolang = $rs[re_prolang];
            $re_ip = $rs[re_ip];
            $re_ussecurity = $rs[re_ussecurity];
            $re_authorize = $rs[re_authorize];
            $re_detail = $rs[re_detail];
            $re_comments = $rs[re_comments];
			$re_regtime  = $rs[re_regtime];
			$re_upload   = $rs[re_upload];
			$re_uploadresume   = $rs[re_uploadresume];
			$re_jobsearchstatus = $rs[re_jobsearchstatus];
			$re_describeme = $rs[re_describeme];
			$re_favoriatebook = $rs[re_favoriatebook];
			$re_highachieve = $rs[re_highachieve];
			$re_iplan = $rs[re_iplan];
			$re_iliketo = $rs[re_iliketo];
			$re_comments = $rs[re_comments];
			$re_prvemployer = $rs[re_prvemployer];
			$re_prvempstatus = $rs[re_prvempstatus];
			$re_professavilable = $rs[re_professavilable];
			$re_currentpay  = $rs[re_currentpay];
			$re_desiredpay= $rs[re_desiredpay];
			$re_benefits= $rs[re_benefits];
			$re_schoolattend= $rs[re_schoolattend];
			$re_personalweb = $rs[re_personalweb];
			$re_private     = $rs[re_private];
	}

	
	?>
     <?       
		$cpforms->formheader(array ('title' => 'Candidate Record','name' => 'article','enctype' => 'multipart/form-data'));
		$cpforms->makehidden(array ('name' => 'action','value' => 'resume_doupdate'));
		$cpforms->makehidden(array ('name' => 'editid','value'=>$editid ));
		if($rs[re_updtime]==0){$rs[re_updtime] = $rs[re_regtime];}
			echo
			'<tr><td colspan="2" class="tbhead" style="margin:0;padding:0">
			<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
			<tr class="firstalt" nowrap><td width="30%" >Create Date:</td><td  width="40%">'. @date("m/d/Y",$rs[re_regtime]).'</td><td rowspan="4" width="30%" ><img src="../uploadfiles/resumes/'.$rs[re_upload].'" width="120" height="120" style="border:1px solid orange"></td></tr>
			<tr class="firstalt" nowrap><td >Last Update:</td><td  >'.@date("m/d/Y",$rs[re_updtime]).'</td></tr>
			<tr class="firstalt" nowrap><td >User Type:</td><td >'.$rs[re_usertype].'</td></tr>
			<tr class="firstalt" nowrap><td >Job Search Status:<font color=red>*</font></td><td  >'.$jobSearchStatus[$rs[re_jobsearchstatus]].'</td></tr>
            </table>
            </td>
            </tr>';

		$cpforms->longline(array('title'=>"Contact Information"));
		$cpforms->gethightext(array ('text' => "First Name",'name' => "re_fname",'only' => 1,'value' => "$re_fname",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Last Name",'name' => "re_lname",'only' => 1,'value' => "$re_lname",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Contact Email",'name' => "re_email",'only' => 1,'value' => "$re_email",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Street Address 1",'name' => "re_address1",'only' => 1,'value' => "$re_address1",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Street Address 2",'name' => "re_address2",'value' => "$re_address2",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Location - City",'only' => 1,'name' => "re_locity",'value' => "$re_locity",'view' => "$view"));
		$cpforms->makeselect(array ('text' => "Location - State",'name' => "re_lostate",'only' => 1,'option' => $state,'selected' => "$re_lostate",'view' => "$view",'viewfunction' => 'state'));
		$cpforms->makeselect(array ('text' => "Location - Country",'name' => "re_locountry",'only' => 1,'option' => $country,'selected' => "$re_locountry",'view' => "$view",'viewfunction' => 'country'));
		$cpforms->gethightext(array ('text' => "Primary Phone",'name' => "re_phone1",'only' => 1,'value' => "$re_phone1",'view' => "$view"));
		$cpforms->maketextarea(array ('text' => "Recruiter Contact",'name' => "re_phone2",'value' => "$re_phone2",'view' => "$view",'icon'=>"'Include recruiter contact information here.  Leave blank if not applicable.', WIDTH, 200, SHADOW, true"));
		$cpforms->gethightext(array ('text' => "Current Job Title",'name' => "re_crtjobtitle",'value' => "$re_crtjobtitle",'view' => "$view"));


		$cpforms->longline(array('title'=>"Desired Job Detail"));
		$cpforms->makeselect(array ('text' => "Desired Job Type",'name' => "re_jobtype",'option' => $jobtype,'only' => 1,'selected' => "$re_jobtype",'view' => "$view"));
		$cpforms->makeselect(array ('text' => "Desired Job Category/Industry",'name' => "re_jobindustry",'option' => $jobcategory,'only' => 1,'selected' => "$re_jobindustry",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Desired Job Title",'name' => "re_jobtitle",'only' => 1,'value' => "$re_jobtitle",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Current Base Pay",'name' => "re_currentpay",'value' => "$re_currentpay",'view' => "$view",'icon'=>"'Indicate current annual base salary', WIDTH, 200, SHADOW, true","prev"=>"$","next"=>"(No Commas)"));
		$cpforms->gethightext(array ('text' => "Desired Base Pay",'name' => "re_desiredpay",'value' => "$re_desiredpay",'view' => "$view",'icon'=>"'Indicate desired annual base salary', WIDTH, 200, SHADOW, true","prev"=>"$","next"=>"(No Commas)"));
		$cpforms->maketextarea(array ('text' => "Other Compensation/Benefits",'name' => "re_benefits",'value' => stripslashes($re_benefits),'view' => "$view",'icon'=>"'Indicate other preferred compensation or benefits such as sign-on bonus or stock grants.  ', WIDTH, 200, SHADOW, true"));
		$cpforms->longline(array('title'=>"Qualifications"));
		$cpforms->maketextarea(array ('text' => "Schools Attended",'name' => "re_schoolattend",'value' => stripslashes($re_schoolattend),'view' => "$view"));

		$cpforms->makeselect(array ('text' => "Years of Work Experience",'name' => "re_yearexp",'only' => 1,'option' => $yearexp2,'selected' => "$re_yearexp",'view' => "$view",'viewfunction' => 'yearexp'));
		$cpforms->makeselect(array ('text' => "Highest Education Level",'name' => "re_edulevel",'only' => 1,'option' => $education,'selected' => "$re_edulevel",'view' => "$view",'viewfunction' => 'education','icon'=>"' Indicate the highest level of education achieved here.', WIDTH, 200, SHADOW, true"));
		$cpforms->gethightext(array ('text' => "Professional Licenses/Certification",'name' => "re_proflicense",'value' => "$re_proflicense",'view' => "$view",'icon'=>"'List all professional licenses or certifications obtained here.', WIDTH, 200, SHADOW, true"));
		$cpforms->makeselect(array ('text' => "Years of People Mgmt Experience",'name' => "re_mgmt",'only' => 1,'option' => $yearexp2,'selected' => "$re_mgmt",'view' => "$view",'viewfunction' => 'yearexp'));
		$cpforms->makeselect(array ('text' => "Years of Profit & Loss Responsibility",'name' => "re_profit",'only' => 1,'option' => $yearexp2,'selected' => "$re_profit",'view' => "$view",'viewfunction' => 'yearexp'));
		$cpforms->gethightext(array ('text' => "Spoken Language(s)",'name' => "re_spoken",'only' => 1,'value' => "$re_spoken",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Programming Language Knowledge",'name' => "re_prolang",'value' => "$re_prolang",'view' => "$view"));
		$cpforms->gethighradio(array ('text' => "High-Tech Patent/IP owner or Co-owner?",'name' => "re_ip",'only' => 1,'selected' => "$re_ip",'view' => "$view"));
		$cpforms->gethighradio(array ('text' => "U.S.Government Security Clearance?",'name' => "re_ussecurity",'only' => 1,'selected' => "$re_ussecurity",'view' => "$view"));
		$cpforms->gethightext(array ('text' => "Authorized to work in the following Country",'name' => "re_authorize",'only' => 1,'value' => $re_authorize,'view' => "$view",'icon'=>"' Indicate in which country the candidate is authorized to work.', WIDTH, 200, SHADOW, true"));
		$cpforms->maketextarea(array ('text' => "Resume Detail",'name' => "re_detail",'only' => 1,'value' => stripslashes($re_detail),'view' => "$view",'icon'=>"' Please include details of all relevant work experience, education and training here.  You can type-in your content or cut and paste them.  Please DO NOT include your name or contact information here.', WIDTH, 200, SHADOW, true"));
       
			$cpforms->longline(array('title'=>"More About Me…"));
			$cpforms->maketextarea(array ('text' => "My family/friends would describe me as…",'name' => "re_describeme",'value' => "$re_describeme",'view' => "$view",'icon'=>"'Please describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
			$cpforms->maketextarea(array ('text' => "My favoriate book is…because…",'name' => "re_favoriatebook",'value' => "$re_favoriatebook",'view' => "$view",'icon'=>"'Please describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
			$cpforms->maketextarea(array ('text' => "My highest achievement is…",'name' => "re_highachieve",'value' => "$re_highachieve",'view' => "$view",'icon'=>"'Please describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
			$cpforms->maketextarea(array ('text' => "In 3 to 5 years, I plan to…",'name' => "re_iplan",'value' => "$re_iplan",'view' => "$view",'icon'=>"'Please describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
			$cpforms->maketextarea(array ('text' => "When I'm not working I like to…",'name' => "re_iliketo",'value' => "$re_iliketo",'view' => "$view",'icon'=>"'Please describe in 250 characters or less.  You may edit this later.', WIDTH, 200, SHADOW, true"));
			$cpforms->maketextarea(array ('text' => "My Personal Website or Blog Link ",'name' => "re_personalweb",'value' => "$re_personalweb",'view' => "$view"));
			$cpforms->maketextarea(array ('text' => "Comments",'name' => "re_comments",'only' => 0,'value' => stripslashes($re_comments),'view' => "$view",'icon'=>"'You may include additional comments here for view by recruiters.', WIDTH, 200, SHADOW, true"));
			$cpforms->makefile(array ('text' => "Picture (Only accept image size less than 50KB.)",'name' => "uploadfile",'value'=>"$re_upload",'url'  => "uploadfiles/resumes/",'view' => "$view"));
			$cpforms->makefile(array ('text' => "Resume File (Only accept doc/docx/txt/pdf files size less than 5MB.)",'name' => "uploadresume",'value'=>"$re_uploadresume",'url'  => "uploadfiles/resumes/",'view' => "$view"));
	
		    $cpforms->longline(array('title'=>"Work Status, Employment and Professional References"));
			$cpforms->gethightext(array ('text' => "Authorized to Work Locations",'name' => "re_prvemployer",'only' => 1,'value' => "$re_prvemployer",'view' => "$view",'icon'=>"'Please list no more than three names separated by a comma (or simply type-in N/A if the applicant does not possess work experience).', WIDTH, 200, SHADOW, true"));
		    $cpforms->gethighradio(array ('text' => "Previous Employment Status Checked?",'name' => "re_prvempstatus",'only' => 1,'selected' => "$re_prvempstatus",'view' => "$view",'icon'=>"'You are not required to perform employment status checking prior to submitting the applicant.  But it may improve your applicant\'s chances of being considered before other applicants.  Be ready to provide the necessary information if requested by the employer.', WIDTH, 200, SHADOW, true"));
			 $cpforms->gethighradio(array ('text' => "Three Professional References Available?",'name' => "re_professavilable",'only' => 1,'selected' => "$re_professavilable",'view' => "$view",'icon'=>"'Does the applicant have a minimum of 3 references available to speak of his/her past work performance?  This is not required but may improve your applicant\'s chances of being considered before others.  Be ready to provide the necessary information if asked by the employer.', WIDTH, 200, SHADOW, true"));
		  $cpforms->longline(array('title'=>"Privacy Status"));
		  $cpforms->gethighradio(array ('text' => "Status",'name' => "re_private",'options'=>$pri_pub,'only' => 1,'selected' => "$re_private",'view' => "$view",'icon'=>"'If you set this as a private resume, it will not be found from others.', WIDTH, 200, SHADOW, true"));


	 ?>


<?
		
      if($_GET[action]=="view"){$cpforms->noformfooter();}
	   else{ $cpforms->formfooter(array('confirm'=>1));}
}


if ($_GET[action]=="list"){


	if($_GET[action]=="list"){   
		$nav = new buildNav;

		$total = $DB->fetch_one_array("SELECT COUNT(*) AS count FROM ".$db_prefix."resume WHERE re_aliasid = 0");

		$nav->total_result = $total[count];

		if (empty($total[count])) {
			pa_exit("<font color=red>No resume!</font><input type=button value='Add New' onclick='location.href=\"resume.php?action=add\"'>");
		}
		$by = "re_id"; 
		$order = "DESC";
        $_GET[order1]==''&&$order1=1;$_GET[order2]==''&&$order2=1;$_GET[order3]==''&&$order3=1;$_GET[order4]==''&&$order4=1;
		$_GET[order5]==''&&$order5=1;$_GET[order6]==''&&$order6=1;$_GET[order7]==''&&$order7=1;$_GET[order8]==''&&$order8=1;$_GET[order9]==''&&$order9=1;
		switch($_GET[swh]){
		   case 1:
			   $by = "re_usertype";
               if($_GET[order1]==1){$order1=2; $order=" DESC ";$image1 = "<img src=\"images/dot1.gif\">";}else{$order1=1;$order=" ASC ";$image1 = "<img src=\"images/dot2.gif\">";}
			   break;
           case 2:
               $by = "re_fname";
               if($_GET[order2]==1){$order2=2; $order=" DESC ";$image2 = "<img src=\"images/dot1.gif\">";}else{$order2=1;$order=" ASC ";$image2 = "<img src=\"images/dot2.gif\">";}
			   break;
		   case 3:
                $by = "re_lname";
               if($_GET[order3]==1){$order3=2; $order=" DESC ";$image3 = "<img src=\"images/dot1.gif\">";}else{$order3=1;$order=" ASC ";$image3 = "<img src=\"images/dot2.gif\">";}
			   break;
		   case 4:
               $by = "re_jobindustry";
               if($_GET[order4]==1){$order4=2; $order=" DESC ";$image4 = "<img src=\"images/dot1.gif\">";}else{$order4=1;$order=" ASC ";$image4 = "<img src=\"images/dot2.gif\">";}
			   break;
			case 5:
			   $by = "re_jobtitle";
               if($_GET[order5]==1){$order5=2; $order=" DESC ";$image5 = "<img src=\"images/dot1.gif\">";}else{$order5=1;$order=" ASC ";$image5 = "<img src=\"images/dot2.gif\">";}
			   break;
           case 6:
               $by = "re_jobtype";
               if($_GET[order6]==1){$order6=2; $order=" DESC ";$image6 = "<img src=\"images/dot1.gif\">";}else{$order6=1;$order=" ASC ";$image6 = "<img src=\"images/dot2.gif\">";}
			   break;
		   case 7:
                $by = "re_locity";
               if($_GET[order7]==1){$order7=2; $order=" DESC ";$image7 = "<img src=\"images/dot1.gif\">";}else{$order7=1;$order=" ASC ";$image7 = "<img src=\"images/dot2.gif\">";}
			   break;
		   case 8:
               $by = "re_lostate";
               if($_GET[order8]==1){$order8=2; $order=" DESC ";$image8 = "<img src=\"images/dot1.gif\">";}else{$order8=1;$order=" ASC ";$image8 = "<img src=\"images/dot2.gif\">";}
			   break;	
		   case 9:
                $by = "re_locountry";
               if($_GET[order9]==1){$order9=2; $order=" DESC ";$image9 = "<img src=\"images/dot1.gif\">";}else{$order9=1;$order=" ASC ";$image9 = "<img src=\"images/dot2.gif\">";}
			   break;
		   case 10:
                $by = "re_regtime";
               if($_GET[order10]==1){$order10=2; $order=" DESC ";$image10 = "<img src=\"images/dot1.gif\">";}else{$order10=1;$order=" ASC ";$image10 = "<img src=\"images/dot2.gif\">";}
			   break;
		   case 11:
                $by = "re_uname";
               if($_GET[order11]==1){$order11=2; $order=" DESC ";$image11 = "<img src=\"images/dot1.gif\">";}else{$order11=1;$order=" ASC ";$image11 = "<img src=\"images/dot2.gif\">";}
			   break;
		}
		
		$order = " ORDER BY $by $order";
		$nav->execute("SELECT * FROM ".$db_prefix."resume WHERE re_aliasid = 0 $order");

    }
	
	echo $nav->title("Resume list");
    echo $nav->pagenav();

    echo "<table border=\"0\" width=\"100%\" cellpadding=\"4\" cellspacing=\"1\" class=\"tableoutline\">
	<script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
	         
               <tr align=\"center\" class=\"tbhead\">
                <td nowrap  width=\"10%\"><a href=\"resume.php?action=list&offset=$_GET[offset]&order1=$order1&swh=1\">$image1 User Type </a></td>
				   <td nowrap  width=\"10%\"><a href=\"resume.php?action=list&offset=$_GET[offset]&order11=$order11&swh=11\">$image11 Username </a></td>
				<td nowrap  width=\"10%\"><a href=\"resume.php?action=list&offset=$_GET[offset]&order10=$order10&swh=10\">$image10 Create Date </a></td>
                <td nowrap  width=\"10%\"><a href=\"resume.php?action=list&offset=$_GET[offset]&order2=$order2&swh=2\">$image2 First Name </a></td>
				 <td nowrap  width=\"10%\"><a href=\"resume.php?action=list&offset=$_GET[offset]&order3=$order3&swh=3\">$image3 Last Name </a></td>
				 <td nowrap  width=\"10%\"><a href=\"resume.php?action=list&offset=$_GET[offset]&order4=$order4&swh=4\">$image4 Industry </a></td>
				 <td nowrap  width=\"10%\"><a href=\"resume.php?action=list&offset=$_GET[offset]&order5=$order5&swh=5\">$image5 Job Title </a></td>
                <td nowrap  width=\"10%\"><a href=\"resume.php?action=list&offset=$_GET[offset]&order6=$order6&swh=6\">$image6 Job Type </a></td>
                <td nowrap  width=\"10%\"><a href=\"resume.php?action=list&offset=$_GET[offset]&order7=$order7&swh=7\">$image7 City </a></td>
				 <td nowrap  width=\"10%\"><a href=\"resume.php?action=list&offset=$_GET[offset]&order8=$order8&swh=8\">$image8 State </a></td>
				 <td nowrap  width=\"10%\"><a href=\"resume.php?action=list&offset=$_GET[offset]&order9=$order9&swh=9\">$image9 Country </a></td>
				 <td nowrap  width=\"10%\"> Action </td>
               </tr>\n";
    while ($list = $DB->fetch_array($nav->sql_result)){
           echo "<tr class=".getrowbg().">
                      <td align=\"left\" nowrap>".ucfirst(strtolower($list[re_usertype]))."</td>
					  <td align=\"left\">".$list[re_uname]."</td>
					  <td align=\"left\" nowrap>".@date('m/d/Y',$list[re_regtime])."</td>
					  <td align=\"left\">".$list[re_fname]."</td>
					  <td align=\"left\">".$list[re_lname]."</td>
					  <td align=\"left\">".$jobcategory[$list[re_jobindustry]]."</td>
					  <td align=\"left\">".$list[re_jobtitle]."</td>
					  <td align=\"left\">".$jobtype[$list[re_jobtype]]."</td>
					  <td align=\"left\">".$list[re_locity]."</td>
					  <td align=\"left\">".$state[$list[re_lostate]]."</td>
					  <td align=\"left\">".$country[$list[re_locountry]]."</td>
                      <td align=\"left\" nowrap><a href=\"resume.php?action=view&offset=$_GET[offset]&id=$list[re_id]\">View</a> | <a href=\"resume.php?action=kill&offset=$_GET[offset]&id=$list[re_id]\">Delete</a>";
    }
	if(empty($total[count])){
			echo "<tr><td><font color=red>No results!</font></td></tr>";
   }
    echo "</table>\n";
    echo $nav->pagenav();
}

if ($_GET[action]=="kill"){
    $cpforms->formheader(array('title'=>'Sure to delete this?'));
    $cpforms->makehidden(array('name'=>'action',
                                'value'=>'remove'));
    $cpforms->makehidden(array('name'=>'resumeid',
                                'value'=>$_GET[id]));
	$cpforms->makehidden(array('name'=>'offset',
                                'value'=>$_GET[offset]));
    $cpforms->formfooter(array('confirm'=>2));
}


if( $_POST[action]=="remove"){
    $DB->query("DELETE FROM ".$db_prefix."resume WHERE re_id='$_POST[resumeid]'");
    redirect("./resume.php?action=list&offset=".$offset,"<font color=red>Deleted Successfully!</font>");
}



cpfooter();
?>